package com.explore.demo.controller;

import com.explore.demo.common.ServerResponse;
import com.explore.demo.service.IndexInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.catalina.Server;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *
 * @author le
 */
@RestController
@RequestMapping("/index")
@ApiOperation("获取首页的数据")
public class IndexInfoController
{

    @Resource
    private IndexInfoService indexInfoService;

    @PostMapping("/query")
    @ApiOperation("通过分类拿到相关职位的简略信息")
    public ServerResponse getInfoByName(@RequestParam("categoryName") String categoryName){
        return indexInfoService.getAllRecruitmentInfo(categoryName);
    }

    @PostMapping("/company/info")
    @ApiOperation("返回每个公司的简略信息")
    public ServerResponse getCompanyList(@RequestParam("categoryName") String categoryName){
        return indexInfoService.getAllCompanyInfo(categoryName);
    }

    @PostMapping("/top_recruitment")
    @ApiOperation("获得最受欢迎的几个职位")
    public ServerResponse getTopRecruitmentInfo(){
        return indexInfoService.getTopRecruitmentInfo();
    }

    @PostMapping("/top_company")
    @ApiOperation("获得最受欢迎的企业")
    public ServerResponse getTopCompanyInfo(){
        return indexInfoService.getTopCompanyInfo();
    }

    @PostMapping("/search")
    @ApiOperation("模糊查询的接口")
    public ServerResponse queryByRecruitOrCompany(@RequestParam("text") String text){
        return indexInfoService.queryDataByCompanyOrRecruit(text);
    }

    @PostMapping("/search_by_place")
    @ApiOperation("通过地点查找对应的招聘信息")
    public ServerResponse queryByPlace(@RequestParam("place") String place){
        return indexInfoService.queryByPlace(place);
    }

    @PostMapping("/more_recruit")
    @ApiOperation("首页的更多职位信息 传入的是分类")
    public ServerResponse getMoreRecruitment(@RequestParam("categoryName") String categoryName){
        return indexInfoService.getMoreRecruitmentInfo(categoryName);
    }

    @PostMapping("/similar_recruit")
    @ApiOperation("传入职位的id 返回对应的相似的职位信息")
    public ServerResponse similarRecruitmentList(@RequestParam("recruitmentId") Integer recruitmentId){
        return indexInfoService.getSimilarRecruitmentByCategoryName(recruitmentId);
    }
}
